<template>
  <el-card :class="cardClass">
    <template #header>
      <div class="card-header">
        <span>{{ title }}</span>
        <span v-if="status" :class="statusClass">{{ status }}</span>
      </div>
    </template>
    <slot></slot>
  </el-card>
</template>

<script setup>
import { defineProps, computed } from 'vue'

const props = defineProps({
  title: {
    type: String,
    required: true
  },
  status: {
    type: String,
    default: ''
  },
  customClass: {
    type: String,
    default: ''
  }
})

const cardClass = computed(() => {
  return props.customClass ? `device-card ${props.customClass}` : 'device-card'
})

const statusClass = computed(() => {
  if (!props.status) return ''
  return `status-${props.status}`
})
</script>

<style scoped>
.device-card {
  margin-bottom: 20px;
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.status-normal {
  color: #4CAF50;
}
.status-warning {
  color: #FFC107;
}
.status-error {
  color: #F44336;
}
</style>